<?php
/**
 * Created by PhpStorm.
 * User: liuda
 * Date: 2018/6/1
 * Time: 18:20
 */
namespace app\index\controller;
use think\Controller;
class Index extends Controller
{

    //首页

    public function index()
    {
        $type = new \app\index\model\Typefile();
        $where = array();
        $where['status'] = 1;
        $where['parent_id'] = array('eq',0);
        $field = '*';
        //list数据
        $list = $type->getList($where, $field);
        $this->assign('list', $list);
        $id = input('id') ? input('id') : 1;
        $model = new \app\index\model\Files();
        $this->assign('typeid', $id);
        /*$tab = $model->getList(array('type' => $id), '*', $order = 'id desc');
        $stype = $type->getList(array('parent_id'=>$id),'*');
        $data = array();
        $data['tab'] = $tab;
        $data['stype'] = $stype;
        $this->assign('tab',  $data['tab']);
        $this->assign('stype',  $data['stype']);*/
        $where = array();
        $where['parent_id'] = $id;
        $typeArr = $type->getList($where, '*');
        if($typeArr){
            foreach ($typeArr as $k=>$v){
                $child = $model->getList(array('stype'=>$v['id']),'*');
                $typeArr[$k]['child'] = $child;
            }
        }
        $this->assign('typeArr', $typeArr);
        return $this->fetch('/Index/index');
    }
}